package com.finalist.util;

import java.util.Random;

import org.apache.commons.lang.math.RandomUtils;

public class MyRandomUtils extends RandomUtils {
	
	private static final char[] ROOT = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 
		'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4',
		'5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', '@', '!' };
	
	public static String getRandomPassword(int length) {
		StringBuilder sb = new StringBuilder();
		Random r = new Random();
		for(int i = 0; i < length ; i++) {
			sb.append(ROOT[Math.abs(r.nextInt()) % ROOT.length]);
		}
		
		return sb.toString();
	}
	
	public static String getRandomNumber(int length) {
		StringBuilder sb = new StringBuilder();
		Random r = new Random();
		for(int i = 0; i < length ; i++) {
			sb.append(Math.abs(r.nextInt()) % 10);
		}
		
		return sb.toString();
	}
	
	public static void main(String[] args) {
		System.out.println("randomNum=========" + getRandomNumber(6));
	}

}
